function spawnCore(ply, command, arguments)
	if(!ValidEntity(ply:GetNetworkedEntity("robot_core"))) then
		local tr = ply:GetEyeTrace();
		local core = ents.Create("gb_core");
		ply:SetNetworkedEntity("robot_core", core);
		core:SetNetworkedEntity("owner", ply);
		core:SetNetworkedInt("health", 100);
		core:SetNetworkedInt("weight", 0);
		core:SetPos(tr.HitPos);
		core:Spawn();
		
		undo.Create("SENT");
		undo.AddEntity(core);
		undo.SetPlayer(ply);
		undo.Finish();
	end
end

concommand.Add("spawn_core", spawnCore);

function removeCore(ply)

end

function enterArena(ply, command, arguments)
	local core = ply:GetNetworkedEntity("robot_core");
	
	if(core && core:IsValid()) then
		if(!core:GetNetworkedBool("in_arena")) then
			core:SetNetworkedVector("build_position", core:GetPos());
			moveContraption(core, getRandomRobotSpawn():GetPos());
			core:SetNetworkedBool("in_arena", true);
			
			local arenaCams = ents.FindByClass("info_arena_cam");
			ply:SetNetworkedVector("build_position", ply:GetPos());
			ply:StripWeapons();
			ply:Spectate(OBS_MODE_CHASE);
			ply:SpectateEntity(core);
		end
	end
end

concommand.Add("enter_arena", enterArena);

function enterWorkshop(ply, command, arguments)
	local core = ply:GetNetworkedEntity("robot_core");
	
	if(core && core:IsValid()) then
		if(core:GetNetworkedBool("in_arena")) then
			moveContraption(core, core:GetNetworkedVector("build_position"));
			core:SetNetworkedBool("in_arena", false);
			ply:UnSpectate();
			giveWeapons(ply);
		end
	end
end

concommand.Add("enter_workshop", enterWorkshop);